from Products.CMFCore.utils import ContentInit
from Products.CMFCore.DirectoryView import registerDirectory

from Products.Archetypes.public import listTypes
from Products.Archetypes.public import process_types

from Products.GenericSetup import EXTENSION
from Products.GenericSetup import profile_registry
from Products.CMFPlone.interfaces import IPloneSiteRoot

#from ownie.shorturl import config
#from ownie.shorturl import permissions

from Products.CMFCore import utils as cmfutils
from Products.CMFPlone.utils import ToolInit

from ownie.shorturl.tools.shortidtool import ShortURLTool

#registerDirectory(config.SKINS_DIR, config.GLOBALS)

def initialize(context):

    #from Products.Bobbles import events

    #content_types, constructors, ftis = process_types(
    #    listTypes(config.PROJECTNAME), config.PROJECTNAME)

    #ContentInit(
    #    config.PROJECTNAME + ' Content',
    #    content_types = content_types,
    #    permission = permissions.ADD_CONTENT_PERMISSION,
    #    extra_constructors = constructors,
    #    fti = ftis,
    #).initialize(context)

    # Register the extension profile
    profile_registry.registerProfile('default', 'ownie.shorturl', 'Short URL service for Own.ie', 
                                     'profiles/default', 'ownie.shorturl', 
                                     EXTENSION,
                                     IPloneSiteRoot)
    cmfutils.ToolInit(
        'ShortURLTool',
        product_name='ownie.shorturl',
        tools=(ShortURLTool,)
        #icon='skins/Bobbles/bobbles_images/bobbles-icon.png'
        ).initialize(context)
        
    #
